package com.wang;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

@SpringBootApplication
public class SpringbootStudyApplication {

    public static void main(String[] args) {
        // 启动方式一（默认）
//		SpringApplication.run(SpringbootStudyApplication.class, args);
        // 启动方式二（builder模式）,方法后边一直“.”的api叫：fluent API（流畅的API）
//        new SpringApplicationBuilder(SpringbootStudyApplication.class).properties("server.port=0").run(args);
        new SpringApplicationBuilder(SpringbootStudyApplication.class).listeners(event -> {
            System.out.println("监听到的事件" + event.getClass().getSimpleName());
        }).properties("server.port=0").run(args);
        // 启动方式三：
//        SpringApplication springApplication = new SpringApplication(SpringbootStudyApplication.class);
        // 设置项目为非Web项目
//		springApplication.setWebApplicationType(WebApplicationType.NONE);
//        Map<String, Object> properties = new LinkedHashMap<>();
        // 随机端口号
//        properties.put("server.port", 0);
//        springApplication.setDefaultProperties(properties);
//        ConfigurableApplicationContext configurableApplicationContext = springApplication.run(args);
//        System.out.println(configurableApplicationContext.getClass().getName());

    }
}
